package data;
import java.io.UnsupportedEncodingException;




/*
字符编码转换类
设置两个静态方法，分别用于两个方向的字符编码转换
 */

public class ChangeString {
    public static String ISOToGBK(String str){
        if (str!=null){
            try {
                str=new String(str.getBytes("Latin1"),"GBK");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return str;
    }

    public static String GBKToISO(String str){
        if (str!=null){
            try {
                str=new String(str.getBytes("GBK"),"Latin1");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return str;
    }
}
